/*
 * @Description: 创建对象工厂模式
 * @Author: rendc
 * @Date: 2021-09-03 09:41:16
 * @LastEditors: rendc
 * @LastEditTime: 2021-09-03 15:30:37
 */
function newPerson (name, age, gender) {
  var p = new Object();
  p.name = name;
  p.age = age;
  p.gender = gender;
  p.sayName = function () {
    console.log(this.name);
  }
  return p;
}
var p1 = newPerson('zhangsan', 12, '男');
var p2 = newPerson('lisi', 15, '女');

console.log(p1);
console.log(p2);

p1.sayName();
p2.sayName();

function newDog (name, age, gender) {
  var d = new Object();
  d.name = name;
  d.age = age;
  d.gender = gender;
  d.sayName = function () {
    console.log("汪汪的名字是" + this.name);
  }
  return d;
}

var d1 = newDog("wangcai", 2, "男");
console.log(d1);
d1.sayName();

console.log(typeof p1);
console.log(typeof d1);

